<?php
/**
 * @package Bike
 * @subpackage Config
 */

/**
 * Configuration class
 * @author Chrome
 * @package Bike
 * @subpackage Config
 */
class Bike_Config {

	/**
	 * Data storage
	 * @var array
	 */
	protected $storage = array();
	
	/**
	 * Constructor
	 * @param array $config
	 */
	public function __construct(array $config){
		$this->storage = $config;
	}
	
	/**
	 * Return value, stored in config by constructor
	 * @param array $pathToSection path in array(indexes)
	 * @throws Bike_Config_Exception
	 * @return mixed
	 */
	public function getValue(array $pathToSection){
		$currentElement = $this->storage;
		foreach($pathToSection as $argument){
			if(isset($currentElement[$argument])){
				$currentElement = $currentElement[$argument];
			}else{
				throw new Bike_Config_Exception('No such index in array', Bike_Config_Exception::NO_SUCH_KEY);
			}
		}
		return $currentElement;
	}
}
